Socket
Socket
Sign inDemoInstall

delegate-properties

Package Overview
Dependencies
17
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    delegate-properties

Deep-clone properties from one object to another and make them non-enumerable, or make existing properties on an object non-enumerable.


Version published
Maintainers
1
Install size
208 kB
Created

Readme

Source

delegate-properties NPM version

Deep-clone properties from one object to another and make them non-enumerable, or make existing properties on an object non-enumerable.

Install

Install with npm

$ npm i delegate-properties --save

Usage

var delegate = require('delegate-properties');
delegate(receiver, provider, clone);

Params

  • receiver: (Object) The object receiving properties
  • provider: (Object) The object providing properties
  • clone: (Boolean) Pass true to deep clone the provider object

Examples

copy properties

Copy properties and make them non-enumerable

var provider = {
  upper: function(val) {
    return val.toUpperCase();
  },
  lower: function(val) {
    return val.toLowerCase();
  }
};

var receiver = {};
// an existing properties in the `receiver` 
// object would be overwritten
delegate(receiver, provider);

receiver.upper('foo'), 'FOO');
receiver.lower('BAR'), 'bar');

console.log(receiver.upper('foo')); // 'FOO' 
console.log(receiver.lower('BAR')); // 'bar'

// copied properties are non-enumerable
console.log(receiver); // {}
console.log(Object.keys(receiver)); // []

make existing properties non-enumerable

var obj = {
  upper: function(val) {
    return val.toUpperCase();
  },
  lower: function(val) {
    return val.toLowerCase();
  }
};

delegate(obj);
console.log(obj) // {}
obj.upper('foo') // 'FOO'
obj.lower('BAR') // 'bar'

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on September 06, 2015.

Keywords

FAQs

Last updated on 06 Sep 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc